package org.jeecg.modules.wlhy.hycarrier.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.wlhy.hycarrier.entity.HyZhenCarrierOrderDriver;
import org.jeecg.modules.wlhy.hycarrier.service.IHyZhenCarrierOrderDriverService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * @Description: 承运商
 * @Author: duanlikao
 * @Date:   2020-12-01
 * @Version: V1.0
 */
@Api(tags="承运商")
@RestController
@RequestMapping("/hycarrier/hyCarrierOrderDriver")
@Slf4j
public class HyZhenCarrierOrderDriverController extends JeecgController<HyZhenCarrierOrderDriver, IHyZhenCarrierOrderDriverService> {
	@Autowired
	private IHyZhenCarrierOrderDriverService hyZhenCarrierOrderDriverService;



	/**
	 *   添加
	 *
	 * @param hyCarrier
	 * @return
	 */
	@AutoLog(value = "承运商-添加")
	@ApiOperation(value="承运商-添加", notes="承运商-添加")
	@PostMapping(value = "/add")
	@RequiresPermissions("sys:carrier:add")
	public Result<?> add(@RequestBody HyZhenCarrierOrderDriver hyCarrier) {

		hyZhenCarrierOrderDriverService.save(hyCarrier);
		return Result.OK("添加成功！");
	}



	/**
	 *  编辑
	 *
	 * @param hyCarrier
	 * @return
	 */
	@AutoLog(value = "承运商-编辑")
	@ApiOperation(value="承运商-编辑", notes="承运商-编辑")
	@PutMapping(value = "/edit")
	@RequiresPermissions("sys:carrier:edit")
	public Result<?> edit(@RequestBody HyZhenCarrierOrderDriver hyCarrier) {

		hyZhenCarrierOrderDriverService.updateById(hyCarrier);
		return Result.OK("编辑成功！");
	}


	/**
	 *   通过id删除
	 *
	 * @param id
	 * @return
	 */
	@AutoLog(value = "承运商-通过id删除")
	@ApiOperation(value="承运商-通过id删除", notes="承运商-通过id删除")
	@DeleteMapping(value = "/delete")
	@RequiresPermissions("sys:carrier:delete")
	public Result<?> delete(@RequestParam(name="id",required=true) String id) {

		hyZhenCarrierOrderDriverService.removeById(id);

		return Result.OK("删除成功!");


	}


	/**
	 * 通过id查询
	 *
	 * @param id
	 * @return
	 */
	@ApiOperation(value="承运商-通过id查询", notes="承运商-通过id查询")
	@GetMapping(value = "/queryById")
	public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
		HyZhenCarrierOrderDriver hyCarrier = hyZhenCarrierOrderDriverService.getById(id);
		if(hyCarrier==null) {
			return Result.error("未找到对应数据");
		}
		return Result.OK(hyCarrier);
	}

    /**
    * 导出excel
    *
    * @param request
    * @param hyCarrier
    */
    @RequestMapping(value = "/exportXls")
	@RequiresPermissions("sys:carrier:exportXls")
	public ModelAndView exportXls(HttpServletRequest request, HyZhenCarrierOrderDriver hyCarrier) {
        return super.exportXls(request, hyCarrier, HyZhenCarrierOrderDriver.class, "承运商");
    }


}
